package com.frogs.ucenter.v1.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.frogs.system.web.api.response.FailResponse;
import com.frogs.system.web.api.response.Response;
import com.frogs.system.web.exception.AppBaseException;
import com.frogs.ucenter.v1.request.WechatUserComplaintRequest;
import com.frogs.ucenter.v1.service.WechatUserComplaintService;
import com.frogs.ucenter.v1.util.ApiConstants;

@Controller(ApiConstants.VERSION+"wechatUserComplaintController")
@RequestMapping("/"+ApiConstants.VERSION)
public class WechatUserComplaintController {

	@Resource(name=ApiConstants.VERSION+"wechatUserComplaintService")
	private WechatUserComplaintService wechatUserComplaintService;

	private static final String WECHAT_USERCOMPLAINT_ADD = "/wechat/userComplaint/add";
	
	@RequestMapping(WECHAT_USERCOMPLAINT_ADD)
	public Response wechatUserComplaintInsert(HttpServletRequest request){
		Response response = null;
		try {
			WechatUserComplaintRequest wucRequest = new WechatUserComplaintRequest();
			wucRequest.parse(request);
			response = wechatUserComplaintService.insertByUserId(wucRequest);
		} catch (Exception e) {
			response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
		}
		return response;
	}
}
